<?php
require_once './model/airport.php';
require_once './model/feedback.php';
require_once './model/daily.php';
require_once './inc/defaults.php';
require_once './model/dangky.php';

class Ajax {

    public static function action_index() {
        
    }

    /**
     * 
     * Form Register
     * @param type $param
     * 
     */
    public static function action_search_list_air($param) {
        $rs_di = Air_Port::findLichBayDi($param);
        if($param["day_back"] == 0 && $param["month_back"] == 0){
            $_SESSION["search_air"] = $rs_di;
            $_SESSION["nguoilon"] = $param["nguoilon"];
            $_SESSION["treem"] = $param["treem"];
            $_SESSION["embe"] = $param["embe"];
            $_SESSION["ngayve"] = 0;
        }else{
            $rs_ve = Air_Port::findLichBayVe($param);
            $_SESSION["search_air"] = $rs_di;
            $_SESSION["search_air_ve"] = $rs_ve;
            $_SESSION["nguoilon"] = $param["nguoilon"];
            $_SESSION["treem"] = $param["treem"];
            $_SESSION["embe"] = $param["embe"];
            $year = getdate();
            $current_year = $year["year"];
            $stamp_back = mktime(0, 0, 0, $param["month_back"], $param["day_back"], $current_year);
            $_SESSION["ngayve"] = $stamp_back;
        }
        echo "1";
    }
    
    public static function action_cart($param) {
        $rs = Air_Port::findOrderById($param);
        $_SESSION["search_order"] = $rs;
        echo "1";
    }
    
    public static function action_add_contact($param)  {
        $rs = Air_Port::addContact($param);
        if(!$rs){
            echo "Add Error!!!";
        }else{
            echo "1";
        }
    }

    public static function action_add_order($param)  {
        $rs = Air_Port::addOrder($param);
        if(!$rs){
            echo "2";
        }else{
            echo Air_Port::getId();
        }
    }
    
    public static function action_add_feedback($param)  {
        $rs = FeedBack::add($param);
        if(!$rs){
            echo "Error!!!";
        }else{
            echo "1";
        }
    }
    
    public static function action_add_dangky($param)  {
        $rs = FeedBack::addDangky($param);
        if(!$rs){
            echo "Error!!!";
        }else{
            echo "1";
        }
    }
    
    public static function action_add_daily($param)  {
        $rs = Daily::add($param);
        if(!$rs){
            echo "Error!!!";
        }else{
            echo "1";
        }
    }
}

?>
